﻿using Heng.Elements.Core.IOC;
using Heng.Elements.Core.Model.Infrastructure.Repositories;
using Heng.Elements.Core.Model.Infrastructure.Services;
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Heng.Elements.Core.Model.Infrastructure.IOC
{
    /// <summary>
    /// IOC module for adding additional bindings to IOC.
    /// Adds entity repositories.
    /// </summary>
    public class ModelIocModule : IIocModule
    {
        public void LoadBindings(Ioc container)
        {
            // add bindings
            container.AddBindings((regBuilder) =>
                {
                    // add bindings for entity repository
                    regBuilder.ForTypesDerivedFrom<IEntityRepository>().ExportInterfaces().SetCreationPolicy(CreationPolicy.NonShared);

                    // add bindings for entity services
                    regBuilder.ForTypesDerivedFrom<IModelService>().ExportInterfaces().SetCreationPolicy(CreationPolicy.NonShared);
                });
        }
    }
}
